﻿#include "CAES.h"
#include <iostream>
#include <io.h>

void printf2char(const char* data, int len) {
    for (int i = 0; i < len; i++)
    {
        std::cout << std::hex << static_cast<unsigned int>(static_cast<unsigned char>(data[i])) << ' ';
    }

    std::cout << std::endl;
}

int main(int argc, char** argv)
{
    char key[] = "1234567890abcdef";
    std::cout << "key: " ;
    printf2char(key, strlen(key) + 1);
    CAES* aes = new CAES(key);

    char str[] = "guoke3915";
    std::cout << "plain: ";
    printf2char(str, strlen(str) + 1);

    int encLen = 0;
    char* enc = (char*)aes->Encrypt(str, strlen(str) + 1, encLen, true);
    std::cout << "cipher: ";
    printf2char(enc, encLen);

    int decLen = 0;
    char* dec = (char*)aes->Decrypt(enc, encLen, decLen);
    std::cout << "decrypt: ";
    printf2char(dec, decLen);

    return 0;
}